

 
use RFS_master_data, clear

* loop over the different transaction cost specifications

    global vars3 "    N_aver N_coun   N_3hour N_BuSe N_IDB   " 

  
    foreach j of global vars3 {
 cap drop yy 
 cap drop xx*
 gen yy = `j'
 gen xx = size
 qui winsor2 xx , replace cuts(1 99)
  qui winsor2 yy , replace cuts(1 99) 
 
 cap estimates drop cc*
 qui {
 	reghdfe yy  xx      , absorb(st0_date#instrumentid        )    cluster(call   st0_date)
  estimates store cc1
 
 	reghdfe yy  xx     , absorb(st0_date#instrumentid call     )    cluster(call   st0_date)
  estimates store cc2

 	reghdfe yy  xx     , absorb(st0_date#instrumentid  call coun      )    cluster(call   st0_date)
  estimates store cc3
   
 	reghdfe yy  xx    , absorb(st0_date#instrumentid mm#call st0_date#coun   )    cluster(call   st0_date)
  estimates store cc4
   
 	reghdfe yy  xx     , absorb(st0_date#instrumentid mm#call st0_date#coun  call#coun  )    cluster(call   st0_date)
  estimates store cc5
    
   
	}
	 esttab cc*  using "RFSbaseline_`j'.tex"  /*  using size_linear_`j'_DS2.tex using size_linear_`j'.tex  */   ///
  , star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace
	
	 esttab cc*  /*  using size_linear_`j'_DS2.tex using size_linear_`j'.tex  */   ///
 , star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace
  } 

    
	
	
 ****************************************** 
 ** ROBUSTNESS: Weighted Regression *******
 ****************************************** 
   
	
	cap drop Ninv
	cap drop aux*
	bys call : gen aux = _n
	bys call: egen aux2 = nvals(aux)
	gen Ninv = 1/aux2
	
   foreach j of global vars3 {
 cap drop yy xx*
 gen yy = `j'
 gen xx = size
 qui winsor2 xx , replace cuts(1 99)
  qui winsor2 yy , replace cuts(1 99) 
 gen xx2 = xx^2
 
 cap estimates drop ee*
 qui {
  	 	reghdfe yy  xx    [aweight = Ninv]  , absorb(st0_date#instrumentid       )    cluster(call   st0_date)
  estimates store ee1
 
 	reghdfe yy  xx    [aweight = Ninv]  , absorb(st0_date#instrumentid  call        )    cluster(call   st0_date)
  estimates store ee2

 	reghdfe yy  xx  [aweight = Ninv]   , absorb(st0_date#instrumentid call coun      )    cluster(call   st0_date)
  estimates store ee3
   
 	reghdfe yy  xx   [aweight = Ninv]   , absorb(st0_date#instrumentid mm#call st0_date#coun   )    cluster(call   st0_date)
  estimates store ee4
   
 	reghdfe yy  xx   [aweight = Ninv]  , absorb(st0_date#instrumentid mm#call st0_date#coun  call#coun  )    cluster(call   st0_date)
  estimates store ee5

	 
	}
	
	 	 esttab ee*  using "APR25_TABLE3_WEIGHT_`j'.tex"     ///
  , star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace

 
  esttab ee*     ///
 , star("*" 0.1 "**" 0.05 "***" 0.01) b(%10.3f) t(%10.2f) scalars(N r2) sfmt(%10.3f)   replace
  } 
  